function x=bandPass(x,loPass,hiPass,samplingRate)
hiPass=max([.1 hiPass]); %can't do zero Hz

if isvector(x)
    if size(x,1)>1
        x=x';
    end
else
    error('x must be vector')
end

if loPass<hiPass || any([loPass hiPass]<0 | [loPass hiPass]>samplingRate/2)
    error('loPass less than hiPass or not in range [0 samplingRate/2]')
end

loPass = loPass/samplingRate;
hiPass = hiPass/samplingRate;
if 0
    X = fft(x);
    myFilt=zeros(1,length(X));
    myFilt(ceil(hiPass*length(X)):floor(loPass*length(X)))=1;
    myFilt(end-floor(loPass*length(X)):end-ceil(hiPass*length(X)))=1;

    X=X.*myFilt;
    x=real(ifft(X));
else
    order = min(floor(length(x)/3.1),500); %larger is better but more expensive, consider kaiserord or
    %firpmord to estimate

    band=[hiPass loPass]/2; %fir1 is in terms of nyquist

    b = fir1(order,band); %default window is hamming, not sure of tradeoffs
    %filtered = fftfilt(b,sig);
    x = filtfilt(b,1,x);
end